#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>

//https://www.nowcoder.com/practice/f2fbd8f61c564ca0b5feaa63ab42dae5?tpId=182&&tqId=34867&rp=1&ru=/ta/exam-all&qru=/ta/exam-all/question-ranking

int main() {
    int n = 0;
    scanf("%d", &n);
    char str[100];
    while (n--) {
        scanf("%s", str);
        int low = 0;
        int up = 0;
        int dig = 0;
        int strSize = strlen(str);
        if (strSize < 8 || isalpha(str[0]) == 0) {
            printf("NO\n");
            continue;
        }
        for (int i = 0; i < strSize; i++) {
            if (islower(str[i]) && low == 0) {
                low++;
            } else if (isupper(str[i]) && up == 0) {
                up++;
            } else if (isdigit(str[i]) && dig == 0) {
                dig++;
            }
        }
        if (low + up + dig > 1) {
            printf("YES\n");
        }
    }
    return 0;
}